<template>
  <div>
    <el-dialog v-bind="{ ...$attrs }">
      <!-- 头部 -->
      <el-row class="header">
        <el-col :span="18" class="left">
          <span style="color: #515151">预警级别：</span>
          <span
            :class="[
              'ml10',
              'mr10',
              {
                warn: formData.headerData.earlyWarningLevel || '' == '一级预警'
              }
            ]"
          >{{ formData.headerData.earlyWarningLevel || '' }}</span>
          <span style="color: #8d8d8d">
            (预警条件：收缴率 &lt;
            {{ formData.headerData.collectionRateValue || '' }} 或催缴率 &gt;
            {{ formData.headerData.dunningRate || '' }})
          </span>
        </el-col>
        <el-col :span="6" class="right">
          <span style="color: #515151">触发时间：</span>
          <span style="color: #8d8d8d">{{ formData.headerData.triggerTime || '' }}</span>
        </el-col>
      </el-row>

      <!-- 表格内容部分 -->
      <el-table
        :data="formData.tableData || ''"
        border
        max-height="300px"
        size="mini"
        class="EWtable"
      >
        <el-table-column prop="No" label="No" min-width="43" align="center"></el-table-column>
        <el-table-column prop="name" label="组织名称" width="160" align="center"></el-table-column>
        <el-table-column label="收缴率（考核）" min-width="160" align="center">
          <template slot-scope="scope">
            <span
              :class="{
                warn:
                  scope.row.collectionRate < formData.headerData.collectionRateValue || ''
              }"
            >{{ scope.row.collectionRate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="催缴率（考核）" min-width="160" align="center">
          <template slot-scope="scope">
            <span
              :class="{
                warn:
                  scope.row.dunningRate > formData.headerData.dunningRate || ''
              }"
            >{{ scope.row.dunningRate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="业主满意度（关联）" min-width="160" align="center">
          <template slot-scope="scope">
            <span
              :class="{
                warn:
                  scope.row.ownerSatisfaction < formData.headerData.collectionRateValue || ''
              }"
            >{{ scope.row.ownerSatisfaction }}</span>
          </template>
        </el-table-column>
        <el-table-column label="业主满意度（关联）" min-width="160" align="center">
          <template slot-scope="scope">
            <span
              :class="{
                warn:
                  scope.row.workOrderRate < formData.headerData.collectionRateValue || ''
              }"
            >{{ scope.row.workOrderRate }}</span>
          </template>
        </el-table-column>
      </el-table>

      <span slot="footer" class="dialog-footer" center>
        <el-button type="primary" size="small" @click="clinkCancle">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    onCancle: {
      type: Function,
      default: () => {}
    },
    formData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      key: 'value'
    }
  },
  methods: {
    clinkCancle() {
      this.onCancle(false)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog__header {
  border-bottom: 1px solid #dedede;
}
.ml10 {
  margin-left: 10px;
}
.mr10 {
  margin-right: 10px;
}
.header {
  // background-color: coral;
  .right {
    padding-right: 10px;
    text-align: right;
  }
}
.EWtable {
  margin-top: 28px;
}
/deep/ .warn {
  color: #f5317f;
  // background-color: cyan;
}
</style>
